<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
<head>
	<title>Base</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="../JSSpec.css" />
	<script type="text/javascript" src="../diff_match_patch.js"></script>
	<script type="text/javascript" src="../JSSpec.js"></script>
	<script type="text/javascript" src="../../javascripts/XQuared.js?load_others=1"></script>
</head>
<body>
<div style='height:0; margin:0; padding:0; overflow:hidden;'>
	<div id="editor"></div>
</div>

<script type="text/javascript" language="javascript">// <![CDATA[
describe("Base",{
	'before': function() {
		var rdom = xq.rdom.Base.createInstance();
		rdom.setWin(window);
		rdom.setRoot(xq.$('editor'));
		
		v = xq.validator.Base.createInstance(null, false);
	},
	
	'should remove HTML comments': function() {
		var invalid = '<p>A</p>';
		var valid = '<p>A</p><!-- B -->';
		
		value_of(v.invalidate(valid).normalizeHtml()).should_be(invalid);
	},
	
	'should not affect original element [[xq.Browser.isTrident || xq.Browser.isGecko]]': function() {
		var invalid = '<strike>Hello</strike>';
		var valid = '<span class="strike">Hello</span>';
		
		xq.$('editor').innerHTML = invalid;
		value_of(v.validate(xq.$('editor')).normalizeHtml()).should_be(valid);
		value_of(xq.$('editor').innerHTML.normalizeHtml()).should_be(invalid);
	},
	
	'should not affect original element [[xq.Browser.isWebkit]]': function() {
		var invalid = '<span class="Apple-style-span" style="text-decoration: line-through;">Hello</span>';
		var valid = '<span class="strike">Hello</span>';
		
		xq.$('editor').innerHTML = invalid;
		value_of(v.validate(xq.$('editor')).normalizeHtml()).should_be(valid);
		value_of(xq.$('editor').innerHTML.normalizeHtml()).should_be(invalid.normalizeHtml());
	},
	
	'should clean-up MS Office specific junks': function() {
		var invalid = '<p>A</p><!--[if gte mso 9]><xml>\n<w:WordDocument>0</w:WordDocument>\r\n</xml><![endif]--><p>B</p>';
		var valid = '<p>A</p><p>B</p>';
		
		xq.$('editor').innerHTML = invalid;
		value_of(v.validate(xq.$('editor')).normalizeHtml()).should_be(valid);
		//value_of(xq.$('editor').innerHTML.normalizeHtml()).should_be(invalid);
	}
});
// ]]></script>
</body>
</html>